package com.aisi.backend.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: shenjianZ
 * @Date: 2024/4/30 下午10:48
 * @Description:
 */



@Data
@AllArgsConstructor
@NoArgsConstructor
public class RestBean<V>{
    private Integer code;
    private String message;
    private V data;

    public static<V> RestBean<V> success(V data){
        return success(RestCode.SUCCESS,data);
    }
    public static<V> RestBean<V> success(RestCode restCode,V data){
        return success(restCode.code,restCode.message,data);
    }
    public static<V> RestBean<V> success(RestCode restCode){
        return success(restCode,null);
    }
    public static<V> RestBean<V> success(Integer code,String message,V data){
        return new RestBean<>(code, message, data);
    }
    public static<V> RestBean<V> failure(V data){
        return failure(RestCode.FAILURE.code,RestCode.FAILURE.message,data);
    }
    public static<V> RestBean<V> failure(RestCode restCode,V data){
        return failure(restCode.code,restCode.message,data);
    }
    public static<V> RestBean<V> failure(RestCode restCode){
        return failure(restCode,null);
    }
    public static<V> RestBean<V> failure(Integer code,String message,V data){
        return new RestBean<>(code, message, data);
    }
}